package com.ruoyi.xm.config;

import com.ruoyi.xm.controller.WebSocketServer;
import com.ruoyi.xm.domain.Task;
import com.ruoyi.xm.mapper.TaskMapper;
import com.ruoyi.xm.service.ITaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class ScheduledTasks {

    //定时任务推送消息
    @Autowired
    public TaskMapper taskMapper;
//    @Scheduled(fixedRate = 5000)
    public void message(){
        List<Task> list = taskMapper.selectToBeContinuedTaskList();
        for (Task task1 : list) {
            WebSocketServer.sendMessageToSpecificClient(task1.getAssignedUserId().toString(),"您有任务未完成,请及时完成");
        }
    }
}
